﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraGrid.Views.Grid;
using COMOSOFT.Class;

namespace COMOSOFT.OrderBusiness.Forms
{
    public partial class FrmAddOrderFactory : Form
    {
        ClassShare cls = new ClassShare("FrmAddOrderFactory");
        FrmFactoryPurchaseMaster frFPM = null;
        string OIDS = null;
        public FrmAddOrderFactory(FrmFactoryPurchaseMaster newFPM)
        {
            InitializeComponent();
            this.frFPM = newFPM;
        }
        private void FrmAddOrderFactory_Load(object sender, EventArgs e)
        {            
            this.sp_SelectOrderFactoryTableAdapter.Fill(this.dataSetOrderManagement.sp_SelectOrderFactory);
        }
        #region[Select PO]
        private void bntOK_Click(object sender, EventArgs e)
        {
            try
            {
                if (gridView_SelectPO.FocusedRowHandle >= 0)
                {
                    int[] numrow = gridView_SelectPO.GetSelectedRows();
                    foreach (int i in numrow)
                    {
                        DataRow row = gridView_SelectPO.GetDataRow(i);
                        if (i == 0)
                            OIDS = row["OID"].ToString();
                        else
                            OIDS += "," + row["OID"].ToString();
                    }
                    cls.UpdateData("sp_FtyPurDetailsInsert", new string[2] { "@OIDs", "@FBID" }, new object[2] { OIDS, ClassShare.fpid });
                    frFPM.LoadFPM();
                }
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        #endregion
    }
}
